require 'sinatra'
require 'mysql'
#require 'config.rb'
require 'active_record'
#require 'CarteFidelite.rb'


ActiveRecord::Base.establish_connection(:adapter => "mysql",
                                        :database => "xl",
                                        :host => "localhost",
                                        :user => "root",
                                        :password => "1A362B9B")

class CarteFidelite  < ActiveRecord::Base

end

get '/' do
  if !request.GET['createcf'].nil?
    "youpi #{request.GET['createcf']}"
  else
    result = CarteFidelite.all;
#    result.inspect
    "mouahaha: #{result.length}"
    result.each do |x|
      "voila   #{x.inspect}"
    end
  end
end

def printResult(res)
  "et hop #{res.nom}"
end
